import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tree_hole/personal/PersonalPage.dart';
import 'qusetion/QuestionPage.dart';
import 'HomePage.dart';
//顶部和底部导航栏
class Tabs extends StatefulWidget{
  String token;
  Tabs(this.token);
  _TabsState createState() => _TabsState();
}
class _TabsState extends State<Tabs> {
  int _currentIndex=0;
  @override
  Widget build(BuildContext context) {

    List _pageList=[HomePage(widget.token), QuestionPage(widget.token), PersonalPage(widget.token)];

    List _pageTitle=[
      '主页','每日问题','个人中心'
    ];
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Container(
          child: Text(
            _pageTitle[_currentIndex],
            style: TextStyle(
              color: Colors.black,
            ),
            textAlign: TextAlign.center,
          ),
        ),
        centerTitle:true,
        backgroundColor: Colors.white,
        titleSpacing: 20,
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: (int index){
          setState(() {
            _currentIndex=index;
            print(_currentIndex);
          });
        },
        iconSize: 35,
        fixedColor: Colors.amber[100],
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.email),label: '主页'),
          BottomNavigationBarItem(icon: Icon(Icons.help_center_rounded),label: '每日问题'),
          BottomNavigationBarItem(icon: Icon(Icons.perm_contact_cal_rounded),label: '个人中心')
        ],
      ),
      body: _pageList[_currentIndex],
    );
  }
}